package com.surprise.db.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import com.surprise.db.entity.SignActivity;

public interface SignActivityRepository extends JpaRepository<SignActivity, Long>{

	@Query("select bd  from signActivity bd  where bd.type=:type and bd.userid=:userid and bd.activeid=:activeid")
	public SignActivity querySignActivity(@Param("type") String type,@Param("userid") String userid,@Param("activeid") long activeid);
	
	@Query("select bd  from signActivity bd  where bd.type=:type and bd.userid=:userid")
	public List<SignActivity> querySignActivityLists(@Param("type") String type,@Param("userid") String userid);
	
	@Query("select bd  from signActivity bd  where bd.type=:type and bd.activeid=:activeid")
	public List<SignActivity> querySignActivityTypeAndAcitive(@Param("type") String type,@Param("activeid") long activeid);
	
	@Modifying(clearAutomatically = true)
	@Transactional
	@Query(value="update signActivity o set o.status=:status where o.id = :id")
	public int update(@Param("status") String d,@Param("id") long k); 
	
}
